package com.xrkj.b2c.service.impl.sys;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.xrkj.b2c.dao.sys.SysRoleMapper;
import com.xrkj.b2c.exception.DataAccessException;
import com.xrkj.b2c.model.sys.SysPrivilege;
import com.xrkj.b2c.model.sys.SysRole;
import com.xrkj.b2c.service.sys.SysRoleService;
/**
 * 角色业务逻辑接口实现类
 * @author 赵子靖
 * @since 2018年07月15日
 *
 */
@Service
public class SysRoleServiceImpl implements SysRoleService{

	@Resource
	private SysRoleMapper sysRoleDao;
	
	/**
	 * 根据属性查询
	 */
	@Transactional(readOnly=true,propagation=Propagation.REQUIRED)
	public List<SysRole> findRole(SysRole role) {
		return sysRoleDao.findRole(role);
	}
	/**
	 * 根据ID删除
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=DataAccessException.class)
	public int deleteRole(String id) {
		return sysRoleDao.deleteRole(id);
	}
	/**
	 * 新增方法
	 * @param role
	 * @return
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=DataAccessException.class)
	public int insertRole(SysRole role) {
		return sysRoleDao.insert(role);
	}
	/**
	 * 新增方法忽略空数据
	 * @param role
	 * @return
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=DataAccessException.class)
	public int insertSelectiveRole(SysRole role) {
		return sysRoleDao.insertSelective(role);
	}
	/**
	 * 修改方法
	 * @param role
	 * @return
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=DataAccessException.class)
	public int update(SysRole role) {
		return sysRoleDao.update(role);
	}
	/**
	 * 修改方法忽略空数据
	 * @param role
	 * @return
	 */
	@Transactional(readOnly=false,propagation=Propagation.REQUIRED,rollbackFor=DataAccessException.class)
	public int updateSelectiveRole(SysRole role) {
		return sysRoleDao.updateSelective(role);
	}
	
	@Override
    public Integer findRoleTotal(Map<String, Object> paramter) {
        return sysRoleDao.findRoleTotal(paramter);
    }

    @Override
    public List<SysRole> findRoleList(Map<String, Object> paramter) {
        return sysRoleDao.findRoleList(paramter);
    }
    
    @Override
    public SysRole selectByPrimaryKey(String id) {
        return sysRoleDao.selectByPrimaryKey(id);
    }
}
